<template>
  <Modal
    :value="value"
    title="施工合同段详情"
    @on-visible-change="handleVisibleChange"
    @on-cancel="handleCancelClick"
  >
    <Form ref="contractForm" :model="contractForm" :label-width="80">
      <div v-if="contractFormType === NodeType.Construction">
        <FormItem label="施工合同段" prop="name">
          <Input v-model="contractForm.name" disabled></Input>
        </FormItem>
        <FormItem label="编码" prop="prefix">
          <Input v-model="contractForm.prefix" disabled></Input>
        </FormItem>
        <FormItem label="起止桩号" prop="qqzh">
          <Input v-model="contractForm.qqzh" disabled></Input>
        </FormItem>
        <FormItem label="施工单位" prop="sgdw_name">
          <Input v-model="contractForm.sgdw_name" disabled></Input>
        </FormItem>
        <FormItem label="监理单位" prop="jldw_name">
          <Input v-model="contractForm.jldw_name" disabled></Input>
        </FormItem>
      </div>
      <div v-else>
        <FormItem label="层级" prop="levelName">
          <Input v-model="contractForm.levelName" disabled></Input>
        </FormItem>
        <FormItem label="类型" prop="levelType">
          <Input v-model="contractForm.levelType" disabled></Input>
        </FormItem>
        <FormItem label="编号" prop="fullcode">
          <Input v-model="contractForm.fullcode" disabled></Input>
        </FormItem>
        <FormItem label="名称" prop="nodeName">
          <Input v-model="contractForm.nodeName" disabled></Input>
        </FormItem>
        <FormItem label="排序" prop="sort">
          <Input v-model="contractForm.sort" disabled></Input>
        </FormItem>
      </div>
    </Form>
    <div slot="footer">
      <Button @click="hanldeCloseClick" type="primary">关闭</Button>
    </div>
  </Modal>
</template>

<script>
import { NodeType } from '@/config/cfg';

export default {
  model: {
    prop: 'value',
    event: 'on-visible-change'
  },
  props: {
    value: Boolean,
    contractForm: {
      type: Object,
      required: true
    },
    contractFormType: Number
  },
  data () {
    return {
      NodeType: NodeType
    };
  },
  methods: {
    handleVisibleChange (visible) {
      this.$emit('on-visible-change', visible);
    },
    hanldeCloseClick () {
      this.$refs.contractForm.resetFields();
      this.$emit('on-visible-change', false);
    },
    handleCancelClick () {
      this.$refs.contractForm.resetFields();
    }
  }
};
</script>

<style lang="less" scoped>
/deep/ .ivu-input[disabled] {
  color: #515a72;
}
</style>
